import 'package:animal/constant/font.dart';
import 'package:animal/utils/screen_util.dart';
import 'package:animal/widgets/image_error.dart';
import 'package:animal/widgets/image_loading.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:getwidget/getwidget.dart';

///商城商品列表item
class ShopListItem extends StatelessWidget {
  final Widget? iconButton;
  final Widget? top;
  final double? borderSize;
  final void Function()? onTap;

  const ShopListItem({Key? key, this.iconButton, this.top, this.borderSize, this.onTap}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: ScreenUtil().L(10), horizontal: ScreenUtil().L(10)),
      margin: EdgeInsets.symmetric(horizontal: ScreenUtil().L(5)),
      decoration: BoxDecoration(border: Border(bottom: BorderSide(width: borderSize??ScreenUtil().L(1.5), color: const Color(0X66B5B5B5)))),
      child: Column(
        children: [
          top ?? Container(),
          InkWell(
            onTap: onTap,
            child: Row(
              children: [
                ClipRRect(
                  borderRadius: BorderRadius.circular(ScreenUtil().L(8)),
                  child: CachedNetworkImage(
                      imageUrl: "https://cdn.pixabay.com/photo/2016/11/22/07/09/spruce-1848543__340.jpg",
                      placeholder: (context, url) => const ImageLoadingWidget(),
                      errorWidget: (controller, url, err) => ImageErrorWidget(),
                      fit: BoxFit.cover,
                      width: ScreenUtil().L(80),
                      height: ScreenUtil().L(80)),
                ),
                Container(width: ScreenUtil().L(10)),
                Expanded(
                  child: Column(
                    children: [
                      Text("Folks免洗洗手液 婴儿粉香(泡沫型)_60ml*1瓶",
                          style: KFontConstant.myTextStyle(size: 15, bold: true, height: 1.5), maxLines: 1, overflow: TextOverflow.ellipsis),
                      Container(height: ScreenUtil().L(7)),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        crossAxisAlignment: CrossAxisAlignment.end,
                        children: [
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text("2kg * 1袋",
                                  style: KFontConstant.myTextStyle(
                                    size: 15,
                                  )),
                              Container(height: ScreenUtil().L(5)),
                              GFBadge(
                                child: Text("包邮",
                                    style: KFontConstant.myTextStyle(
                                      size: 12,
                                      color: const Color(0XFFFF5B5D)
                                    )),
                                color: Colors.transparent,
                                size: ScreenUtil().L(35),
                                border: BorderSide(
                                  width: ScreenUtil().L(1.5),
                                  color: const Color(0XFFFF5B5D),
                                ),
                              ),
                              Container(height: ScreenUtil().L(15)),
                              Text("¥ 4999", style: KFontConstant.myTextStyle(size: 14, color: const Color(0XFFFF5B5D), bold: true)),
                            ],
                          ),
                          iconButton ?? Container()
                        ],
                      ),
                    ],
                  ),
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
